@@ -5,7 +5,7 @@ module Agents |
||
5 | 5 |
cannot_create_events! |
6 | 6 |
|
7 | 7 |
DEFAULT_WEBHOOK = 'incoming-webhook' |
8 |
- |
|
8 |
+ DEFAULT_USERNAME = 'Huginn' |
|
9 | 9 |
description <<-MD |
10 | 10 |
The SlackAgent lets you receive events and send notifications to [slack](https://slack.com/). |
11 | 11 |
|
@@ -28,7 +28,7 @@ module Agents |
||
28 | 28 |
'team_name' => 'your_team_name', |
29 | 29 |
'auth_token' => 'your_auth_token', |
30 | 30 |
'channel' => '#general', |
31 |
- 'username' => "Huginn", |
|
31 |
+ 'username' => DEFAULT_USERNAME, |
|
32 | 32 |
'message' => "Hey there, It's Huginn", |
33 | 33 |
'webhook' => DEFAULT_WEBHOOK |
34 | 34 |
} |
@@ -45,11 +45,15 @@ module Agents |
||
45 | 45 |
end |
46 | 46 |
|
47 | 47 |
def webhook |
48 |
- options[:webhook].present? ? options[:webhook] : DEFAULT_WEBHOOK |
|
48 |
+ options[:webhook].presence || DEFAULT_WEBHOOK |
|
49 |
+ end |
|
50 |
+ |
|
51 |
+ def username |
|
52 |
+ options[:username].presence || DEFAULT_USERNAME |
|
49 | 53 |
end |
50 | 54 |
|
51 | 55 |
def slack_notifier |
52 |
- @slack_notifier ||= Slack::Notifier.new(options[:team_name], options[:auth_token], webhook) |
|
56 |
+ @slack_notifier ||= Slack::Notifier.new(options[:team_name], options[:auth_token], webhook, username: username) |
|
53 | 57 |
end |
54 | 58 |
|
55 | 59 |
def receive(incoming_events) |